import type { PageParam, PageResult } from '@vben/request';
import type { Dayjs } from 'dayjs';

import { requestClient } from '#/api/request';

export namespace AcquisitionAgriculturalMachineryOperationApi {
  /** 农机作业信息 */
  export interface AgriculturalMachineryOperation {
    id: number; // 主键ID
    licensePlate?: string; // 车牌号
    driverName?: string; // 司机姓名
    driverPhone?: string; // 司机电话
    operationDate?: string | Dayjs; // 作业日期
    operationArea?: number; // 作业面积（亩）
    qualifiedArea?: number; // 达标面积（亩）
    projectArea?: number; // 项目面积（亩）
    reportingYearMonth: string; // 上报年月（格式：YYYY-MM）
  }
}

/** 查询农机作业分页 */
export function getAgriculturalMachineryOperationPage(params: PageParam) {
  return requestClient.get<PageResult<AcquisitionAgriculturalMachineryOperationApi.AgriculturalMachineryOperation>>(
    '/acquisition/agricultural-machinery-operation/page',
    { params },
  );
}

/** 查询农机作业详情 */
export function getAgriculturalMachineryOperation(id: number) {
  return requestClient.get<AcquisitionAgriculturalMachineryOperationApi.AgriculturalMachineryOperation>(
    `/acquisition/agricultural-machinery-operation/get?id=${id}`,
  );
}

/** 新增农机作业 */
export function createAgriculturalMachineryOperation(data: AcquisitionAgriculturalMachineryOperationApi.AgriculturalMachineryOperation) {
  return requestClient.post('/acquisition/agricultural-machinery-operation/create', data);
}

/** 修改农机作业 */
export function updateAgriculturalMachineryOperation(data: AcquisitionAgriculturalMachineryOperationApi.AgriculturalMachineryOperation) {
  return requestClient.put('/acquisition/agricultural-machinery-operation/update', data);
}

/** 删除农机作业 */
export function deleteAgriculturalMachineryOperation(id: number) {
  return requestClient.delete(`/acquisition/agricultural-machinery-operation/delete?id=${id}`);
}

/** 批量删除农机作业 */
export function deleteAgriculturalMachineryOperationList(ids: number[]) {
  return requestClient.delete(
    `/acquisition/agricultural-machinery-operation/delete-list?ids=${ids.join(',')}`,
  );
}

/** 导出农机作业 */
export function exportAgriculturalMachineryOperation(params: any) {
  return requestClient.download('/acquisition/agricultural-machinery-operation/export-excel', { params });
}